package com.sc.nft.admin.request;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.NumberUtil;
import com.sc.nft.dto.profit.BusinessShareProfitDTO;
import com.sc.nft.exception.GlobalRunTimeException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

@Data
public class EcologyHatchMapRatioRequest {

    @ApiModelProperty("版图省级分红比例")
    @NotNull(message = "版图省级分红比例不能為空")
    @Range(min = 0, max = 1, message = "版图省级分红比例只能在0-1之间")
    private BigDecimal metaMapProvinceRatio;
    @ApiModelProperty("版图市级分红比例")
    @NotNull(message = "版图市级分红比例不能為空")
    @Range(min = 0, max = 1, message = "版图市级分红比例只能在0-1之间")
    private BigDecimal metaMapCityRatio;

    @ApiModelProperty("版图区级分红比例")
    @NotNull(message = "版图区级分红比例不能為空")
    @Range(min = 0, max = 1, message = "版图区级分红比例只能在0-1之间")
    private BigDecimal metaMapRegionRatio;


    public void checkRatio() {
        BigDecimal sumRatio = metaMapProvinceRatio.add(metaMapCityRatio).add(metaMapRegionRatio);
        if (sumRatio.compareTo(BigDecimal.ONE) > 0) {
            throw new GlobalRunTimeException("总分润比例合计大于100%");
        }
    }

}
